package springbean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import springbean.bean.Person;

/**
 * Hello world!
 *
 */
public class App
{
    public static void main( String[] args )
    {
        //根据classpath路径获取
        System.out.println("现在开始初始化容器");
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("spring-bean.xml");
        System.out.println("现在开始初始化成功");
        //根据文件路径
//        ApplicationContext applicationContext=new FileSystemXmlApplicationContext("file:/Users/xiao/Desktop/project/java-frames/springbean/target/classes/spring-bean.xml");
//        BeanFactory factory = new XmlBeanFactory(new ClassPathResource("spring-bean.xml"));
        Person person= applicationContext.getBean("person",Person.class);

        System.out.println(person);

        //
        System.out.println("现在关闭初始化容器");
        ((ClassPathXmlApplicationContext)applicationContext).registerShutdownHook();
    }
}
